﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Status.aspx.cs" Inherits="P.InOut.NetMvc.Components.ProfileComponent.Views.Status" %>
<%@ Import Namespace="P.InOut.NetMvc.Controllers" %>

<div id="userSplash">
    <span id="statusName"><%= ViewData.Model.Profile.FirstName == null ||
                                ViewData.Model.Profile.FirstName == string.Empty ? 
                                ViewData.Model.Profile.Aspnet_Membership.Aspnet_User.UserName : 
                                ViewData.Model.Profile.FirstName + " " 
                                + ViewData.Model.Profile.LastName %>
    </span>
    <span id="statusElapsed">▲ <%= P.InOut.NetMvc.Common.Utilities.GetTimeElapsed(ViewData.Model.Profile.DateTimeLastUpdated) %></span>
</div>
<div id="inStatusContainer">
<%  string selected = string.Empty;
    if (ViewData.Model.Profile.InStatus == true) { selected = "In"; } else { selected = "Out"; } 
    
    using (Html.Form<ProfilesController>(action => action.Update(ViewData.Model.Profile.UserId), FormMethod.Post, new { id = "inStatusForm" })) { %>
    <% if (ViewData.Model.Profile.UserId == (Guid)Membership.GetUser().ProviderUserKey) { %>
        
        <%= Html.Hidden("RequestFrom", "Updates") %>
        I'm currently:
        <%= Html.DropDownList("inStatus", new SelectList(new string[] { "In", "Out" }, selected))%>
        
        Location: 
        <% string location = string.Empty;
           if (ViewData.Model.Profile.OfficeStatus == true) { location = "Office"; } else { location = "Remote"; }
           if (ViewData.Model.Profile.InStatus) { %>
           
                <%= Html.DropDownList("officeStatus", new SelectList(new string[] { "Office", "Remote" }, location)) %>
           
           <% } %>
        
    <% } else { %>
        
        I'm currently <%= selected%>
        
    <% } %>
<% } %>
</div>

<div id="statusFormContainer">
    <!-- // Create form for updating Profile.Status and point to the correct Controller/Method -->
    <% using (Html.Form<ProfilesController>(action => action.Update(ViewData.Model.Profile.UserId), FormMethod.Post, new { id = "statusForm" })) { %>
       
       <%= Html.Hidden("RequestFrom", "Updates") %>
       <!-- // Only allow the status to be edited if the status shown is for the logged in user -->
       <% if (ViewData.Model.Profile.UserId == (Guid)Membership.GetUser().ProviderUserKey) { %>
       
            <!-- // Create textarea to show current status and allow the updating of Profile.Status -->
            <textarea id="StatusText" name="Status" cols="10" rows="2"><%= ViewData.Model.Profile.Status%></textarea>
        <div>
            <%= Html.SubmitButton("Update", "Update", new { cssClass = "submitButton" })%>
        </div>
        
        <% } else { %>
        
            <textarea name="Status" cols="37" rows="2" disabled="disabled"><%= ViewData.Model.Profile.Status%></textarea>
        
        <% } %>
        
    <% } %>
</div>